home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / FormattedTextFieldBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  5KB  |  156 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  09/07/97    LAB    Fixed misspelling of descriptions.
  8. //  10/08/97    LAB    Added interaction for setFillMask (Addresses Mac Bug #8517).
  9. //                    Removed EditFont interactions and property.
  10. //  10/11/97    LAB    Removed setFillMask interaction because it was redundant with base
  11. //                    classes set text to empty string interaction (Ooops. Addresses Mac
  12. //                    Bug #9133)
  13. //  08/19/98    LAB    Moved to GroupAWTAdditions folder.
  14.  
  15. /**
  16.  * BeanInfo for FormattedTextField.
  17.  *
  18.  */
  19. public class FormattedTextFieldBeanInfo extends SimpleBeanInfo {
  20.  
  21.     /**
  22.      * Constructs a FormattedTextFieldBeanInfo object.
  23.      */
  24.     public FormattedTextFieldBeanInfo() {
  25.     }
  26.  
  27.     /**
  28.      * Gets a BeanInfo for the superclass of this bean.
  29.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  30.      */
  31.     public BeanInfo[] getAdditionalBeanInfo() {
  32.         try {
  33.             BeanInfo[] bi = new BeanInfo[1];
  34.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  35.             return bi;
  36.         }
  37.         catch (IntrospectionException e) { throw new Error(e.toString());}
  38.     }
  39.  
  40.     /**
  41.      * Gets the SymantecBeanDescriptor for this bean.
  42.      * @return an object of type SymantecBeanDescriptor
  43.      * @see symantec.itools.beans.SymantecBeanDescriptor
  44.      */
  45.     public BeanDescriptor getBeanDescriptor() {
  46.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  47.         String s=group.getString("GroupAWTAdditions"); 
  48.  
  49.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  50.         bd.setFolder(s);
  51.         bd.setToolbar(s);
  52.         bd.setWinHelp("0x123AE");
  53.  
  54.         return (BeanDescriptor) bd;
  55.     }
  56.  
  57.     /**
  58.      * Gets an image that may be used to visually represent this bean
  59.      * (in the toolbar, on a form, etc).
  60.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  61.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  62.      * @return an image for this bean, always color even if requested monochrome
  63.      * @see BeanInfo#ICON_MONO_16x16
  64.      * @see BeanInfo#ICON_COLOR_16x16
  65.      * @see BeanInfo#ICON_MONO_32x32
  66.      * @see BeanInfo#ICON_COLOR_32x32
  67.      */
  68.     public java.awt.Image getIcon(int iconKind) {
  69.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  70.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  71.             java.awt.Image img = loadImage("FormattedTextFieldC16.gif");
  72.             return img;
  73.         }
  74.  
  75.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  76.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  77.             java.awt.Image img = loadImage("FormattedTextFieldC32.gif");
  78.             return img;
  79.         }
  80.  
  81.         return null;
  82.     }
  83.  
  84.     /**
  85.      * Gets an array of descriptions of the methods used for "connections" by
  86.      * Visual CafΘ's Interaction Wizard.
  87.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  88.      * @return method descriptions for this bean
  89.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  90.      */
  91.     public MethodDescriptor[] getMethodDescriptors() {
  92.         Class[] args;
  93.         ConnectionDescriptor connection;
  94.         java.util.Vector connections;
  95.         java.util.Vector md = new java.util.Vector();
  96.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  97.         String s;
  98.  
  99.         try{
  100.             args = null;
  101.             MethodDescriptor getMask = new MethodDescriptor(beanClass.getMethod("getMask", args));
  102.  
  103.             connections = new java.util.Vector();
  104.             connection = new ConnectionDescriptor("output", "String", "",
  105.                                     "%name%.getMask()",
  106.                                     conn.getString("getMask"));
  107.             connections.addElement(connection);
  108.  
  109.             getMask.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  110.             md.addElement(getMask);
  111.         } catch (Exception e) { throw new Error("getMask:: " + e.toString()); }
  112.  
  113.         try{
  114.             args = new Class[1];
  115.             args[0] = java.lang.String.class ;
  116.             MethodDescriptor setMask = new MethodDescriptor(beanClass.getMethod("setMask", args));
  117.  
  118.             connections = new java.util.Vector();
  119.             connection = new ConnectionDescriptor("input", "String", "",
  120.                                     "%name%.setMask(%arg%);",
  121.                                     conn.getString("setMask"));
  122.             connections.addElement(connection);
  123.  
  124.             setMask.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  125.             md.addElement(setMask);
  126.         } catch (Exception e) { throw new Error("setMask:: " + e.toString()); }
  127.  
  128.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  129.         md.copyInto(rv);
  130.  
  131.         return rv;
  132.     }
  133.  
  134.     /**
  135.      * Returns descriptions of this bean's properties.
  136.      */
  137.     public PropertyDescriptor[] getPropertyDescriptors() {
  138.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  139.         String s;
  140.  
  141.         try{
  142.         PropertyDescriptor mask = new PropertyDescriptor("mask", beanClass);
  143.         mask.setBound(true);
  144.         mask.setConstrained(false);
  145.         mask.setDisplayName(prop.getString("mask"));
  146.  
  147.         PropertyDescriptor[] rv = {
  148.             mask
  149.             };
  150.         return rv;
  151.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  152.     }
  153.  
  154.     private final static Class beanClass = FormattedTextField.class;
  155.  
  156.     }    //  end of class FormattedTextFieldBeanInfo